(function(){
	  var hash = location.hash.slice(1).replace(/\s+/g,"");
	  var page = 1;
	  var maxPage ;
	  function getContentJson(fn){
		  hash = location.hash.slice(1).replace(/\s+/g,"");
		  location.hash = "#" + decodeURI(hash);
		  $.post('../../portal/courselibrary/searchCourse.json',{queryCourseName: decodeURI(hash),currentPage:page},function(result){
			  var contentDOM = _.template($('#searchTpl').html())(result.data);
            
			  $('.courseSearchContent').html(contentDOM);
			  
			  page = result.data.currentPage;
			  
			  maxPage = result.data.maxPage;
			  if(fn){fn(maxPage)};	
		  })
		  $.get('../../portal/courselibrary/findCourseByLabelCode.json?labelCode=uuid-label-recourse&queryCount=5',function(result){
			 //转换时间戳
			  $.each(result.data.listCourse,function(index,val){
				  var t = new Date(val.modifyTime);
				  val.modifyTime = t.getMonth() + 1 + '/' + t.getDate();
			  })
			  var sliderDOM = _.template($('#courseSearchSliderTpl').html())(result.data);
			  console.log(result.data);
			  $('.live-course-body .es-live-recommend').html(sliderDOM);
		  })
	  }
	  getContentJson(pageComponents);
	  //监听hash改变
	  $(window).bind('hashchange', function() {		  
		  getContentJson(pageComponents);		
	  });
	  //将翻页组件提出来
	  function pageComponents(maxPage){
	  	  var maxPage = maxPage;
	  	  //将翻页组件插入进来
	  	  var components = new PageNum(maxPage);
	  	  //为翻页添加事件；
	  	  components.events(function(num){
	  		      page = num;
	  			  getArticleList();
	  	  })
	  }
	 	  
})()